import collections
class Solution(object):
    def deckRevealedIncreasing(self, deck):
        n = len(deck)
        deck.sort()
        id = collections.deque([i for i in range(n)])
        out = []
        state = 0
        while id:
            if state == 0:
                out.append(id.popleft())
                state = 1
            else:
                id.append(id.popleft())
                state = 0
        r_out = [0] * n
        for i in range(n):
            r_out[out[i]] = deck[i]
        return r_out



data = Solution()
deck = [17,13,11,2,3,5,7]
print(data.deckRevealedIncreasing(deck))